<?
if (!defined('SMF'))
	die('Hacking attempt...');

global $smcFunc, $txt, $scripturl, $user_info;
global $dbtables;

// Verify user login, if CheckLogin() returns false return to the calling script/function
if (CheckLogin() == false)
	return;

bigtitle($txt['bnt_ship_title']);

//-------------------------------------------------------------------------------------------------

// Pull player sector into $playerinfo.
$result = $smcFunc['db_query']('', '
	SELECT *
	FROM {raw:db_ships}
	WHERE user_id = {int:user_id}
	LIMIT 1',
	array(
		'db_ships' => $dbtables['ships'],
		'user_id' => $user_info['id'],
	)
);
$playerinfo = $smcFunc['db_fetch_assoc']($result);
$smcFunc['db_free_result']($result);

$ship_id = (isset($_GET['ship_id'])) ? $_GET['ship_id'] : '';

// Get opposing ship information
$result = $smcFunc['db_query']('', '
	SELECT ship_name, character_name, sector
	FROM {raw:db_ships}
	WHERE ship_id = {int:ship_id}
	LIMIT 1',
	array(
		'db_ships' => $dbtables['ships'],
		'ship_id' => $ship_id
	)
);
$othership = $smcFunc['db_fetch_assoc']($result);
$smcFunc['db_free_result']($result);

if ($othership['sector'] != $playerinfo['sector'])
	echo $txt['bnt_ship_the'], ' <font color="white">', $othership['ship_name'], '</font>, ', $txt['bnt_ship_nolonger'], ' ', $playerinfo['sector'], '<br>';
else
{
	echo $txt['bnt_ship_youc'], ' <font color="white">', $othership['ship_name'], '</font>, ', $txt['bnt_ship_owned'], ' <font color="white">', $othership['character_name'], '</font>.<br><br>
	', $txt['bnt_ship_perform'], '<br><br>
	<a href=', $scripturl, '?action=blacknova;sa=scan;ship_id=', $ship_id, '>', $txt['bnt_planet_scn_link'], '</a><br>
	<a href=', $scripturl, '?action=blacknova;sa=attack;ship_id=', $ship_id, '>', $txt['bnt_planet_att_link'], '</a><br>
	<a href=', $scripturl, '?action=blacknova;sa=mailto;to=', $ship_id, '>', $txt['bnt_send_msg'], '</a><br>';
}

echo '<br>';
TextMainMenu();
?>
